<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class BaseMapBase extends Base {
	//table
	var $table_from = '';
	var $table_to = '';
	
	//key
	var $table_from_key = '';
	var $table_to_key = '';
	
	//one2one, one2many, many2many
	var $relation = '';
	
	//constructor
	function BaseMapBase() {
		parent::Base();
	}
	
	//methods
	function getItemsFrom($filter = '', $limit = true) {
		$query_limit_str = "";
		if( $limit == true ) {
			$query_limit_str = $this->getQueryLimitStr();
		}
		
		$query = "select f.* from " . $this->table_from . " f, " . $this->table_to . " t " 
				. " where f." . $this->table_from_key . " = t." . $this->table_to_key . " ";
		$query .= $this->_get_query_str($filter);
		$query .= $query_limit_str;
		
		return $this->adb->getRows($query);
	}
	
	function getItemsTo($filter = '', $limit = true) {
		$query_limit_str = "";
		if( $limit == true ) {
			$query_limit_str = $this->getQueryLimitStr();
		}
		
		$query = "select t.* from " . $this->table_from . " f, " . $this->table_to . " t " 
				. " where f." . $this->table_from_key . " = t." . $this->table_to_key . " ";
		$query .= $this->_get_query_str($filter);
		$query .= $query_limit_str;
		
		return $this->adb->getRows($query);
	}
	
	function getItemsFromTo($filter = '', $limit = true) {
		$query_limit_str = "";
		if( $limit == true ) {
			$query_limit_str = $this->getQueryLimitStr();
		}
		
		$query = "select f.*, t.* from " . $this->table_from . " f, " . $this->table_to . " t " 
				. " where f." . $this->table_from_key . " = t." . $this->table_to_key . " ";
		$query .= $this->_get_query_str($filter);
		$query .= $query_limit_str;
		
		return $this->adb->getRows($query);
	}
	
	//
	function _get_query_str($filter = '', $check = 0) {
		
	}
}
//
?>